<?php
/**
 * Created by PhpStorm.
 * User: PHP
 * Date: 2021/6/9
 * Time: 17:06
 */

namespace App\Http\Admin\Controllers\Config;
use App\Http\Controllers\Controller;
use Hlcreation\Basic\Helper;
use Illuminate\Http\Request;
use App\Requests\UploadRequest;

use App\Services\config\SmsServices;

class SmsController extends Controller
{

    public function __construct(SmsServices $services)
    {
        $this->services = $services;
    }


    /**
     *  阿里云短信配置
     * */

    //添加阿里云存储配置
    public function smsadd(UploadRequest $request){

        $all = $request->all();

        $userInfo = Helper::getPost('userinfo');
        $all['creator_uid'] = $userInfo['user_info']['id'];  //创建者
        $all['created_at'] = date("Y-m-d H:i:s");

        $data = $this->services->addSms($all);

        if ($data){
            return Helper::toJson('添加短信配置成功 ',200);
        }else{
            return Helper::toJson('添加短信配置失败 ',400);
        }


    }






    //查看阿里云短信信息
    public function smsinfo(Request $request){

        $userInfo = Helper::getPost('userinfo');

        $uid = $userInfo['user_info']['id'];  //创建者

        $type = $request->only('type');

        $data = $this->services->smsInfo($uid,$type);

        return  Helper::toJson('短信配置详情 ',200,$data);

    }



    ############################################################################################################












}
